﻿using System;
using System.Collections.Generic;

namespace SharpSqlAnalyzer.nodes
{
	// Token: 0x02000337 RID: 823
	public class TPivotedTable : TParseTreeNode
	{
		// Token: 0x170006E3 RID: 1763
		// (get) Token: 0x060021BF RID: 8639 RVA: 0x0033432B File Offset: 0x0033252B
		// (set) Token: 0x060021C0 RID: 8640 RVA: 0x00334333 File Offset: 0x00332533
		public virtual TJoinList Joins
		{
			get
			{
				return this.joins;
			}
			set
			{
				this.joins = value;
			}
		}

		// Token: 0x170006E4 RID: 1764
		// (get) Token: 0x060021C1 RID: 8641 RVA: 0x0033433C File Offset: 0x0033253C
		// (set) Token: 0x060021C2 RID: 8642 RVA: 0x00334344 File Offset: 0x00332544
		public virtual List<TPivotClause> PivotClauseList
		{
			get
			{
				return this.pivotClauseList;
			}
			set
			{
				this.pivotClauseList = value;
			}
		}

		// Token: 0x170006E5 RID: 1765
		// (get) Token: 0x060021C4 RID: 8644 RVA: 0x00334356 File Offset: 0x00332556
		// (set) Token: 0x060021C3 RID: 8643 RVA: 0x0033434D File Offset: 0x0033254D
		public virtual TTable TableSource
		{
			get
			{
				return this.tableSource;
			}
			set
			{
				this.tableSource = value;
			}
		}

		// Token: 0x170006E6 RID: 1766
		// (get) Token: 0x060021C5 RID: 8645 RVA: 0x0033435E File Offset: 0x0033255E
		// (set) Token: 0x060021C6 RID: 8646 RVA: 0x00334366 File Offset: 0x00332566
		public virtual TPivotClause PivotClause
		{
			get
			{
				return this.pivotClause;
			}
			set
			{
				this.pivotClause = value;
			}
		}

		// Token: 0x170006E7 RID: 1767
		// (get) Token: 0x060021C7 RID: 8647 RVA: 0x0033436F File Offset: 0x0033256F
		// (set) Token: 0x060021C8 RID: 8648 RVA: 0x00334377 File Offset: 0x00332577
		public virtual TFromTable FromTableSource
		{
			get
			{
				return this.fromTableSource;
			}
			set
			{
				this.fromTableSource = value;
			}
		}

		// Token: 0x060021C9 RID: 8649 RVA: 0x00334380 File Offset: 0x00332580
		public override void init(object arg1, object arg2)
		{
			this.joins = new TJoinList();
			this.pivotClauseList = new List<TPivotClause>();
			this.fromTableSource = (TFromTable)arg1;
			this.pivotClause = (TPivotClause)arg2;
			this.pivotClauseList.Add(this.pivotClause);
		}

		// Token: 0x060021CA RID: 8650 RVA: 0x003343CC File Offset: 0x003325CC
		public override void doParse(TCustomSqlStatement psql, ESqlClause plocation)
		{
			TJoin tjoin;
			if (this.fromTableSource.FromtableType != ETableSource.join)
			{
				tjoin = new TJoin();
				TTable ttable = psql.analyzeFromTable(this.fromTableSource, new bool?(true));
				this.tableSource = ttable;
				ttable.EffectType = ETableEffectType.tetSelect;
				tjoin.Table = ttable;
				tjoin.startToken = tjoin.Table.startToken;
				tjoin.endToken = tjoin.Table.endToken;
				tjoin.GSharpSqlParser = this.GSharpSqlParser;
			}
			else
			{
				tjoin = psql.analyzeJoin(this.fromTableSource.JoinExpr, null, new bool?(true));
				tjoin.doParse(psql, ESqlClause.join);
			}
			this.joins.addJoin(tjoin);
			foreach (TPivotClause tpivotClause in this.pivotClauseList)
			{
				tpivotClause.doParse(psql, plocation);
			}
		}

		// Token: 0x060021CB RID: 8651 RVA: 0x003344BC File Offset: 0x003326BC
		public override void accept(TParseTreeVisitor v)
		{
			v.preVisit(this);
			v.postVisit(this);
		}

		// Token: 0x060021CC RID: 8652 RVA: 0x003344CC File Offset: 0x003326CC
		public override void acceptChildren(TParseTreeVisitor v)
		{
			v.preVisit(this);
			this.joins.acceptChildren(v);
			foreach (TPivotClause tpivotClause in this.pivotClauseList)
			{
				tpivotClause.acceptChildren(v);
			}
			v.postVisit(this);
		}

		// Token: 0x04001ABE RID: 6846
		private TPivotClause pivotClause;

		// Token: 0x04001ABF RID: 6847
		private TFromTable fromTableSource;

		// Token: 0x04001AC0 RID: 6848
		private TTable tableSource;

		// Token: 0x04001AC1 RID: 6849
		private List<TPivotClause> pivotClauseList;

		// Token: 0x04001AC2 RID: 6850
		private TJoinList joins;
	}
}
